
namespace Core.Mapping
{
    public class WorldChunk
    {
        //public int Width { get { return _Width; } }
        //public int Height { get { return _Height; } }
        //public Rectangle ChunkRectangle { get { return _ChunkRectangle; } }

        //protected int _Width;
        //protected int _Height;
        //protected Rectangle _ChunkRectangle;

        //Tile[] _Tiles;

        //public WorldChunk(Tile[] Tiles, Rectangle ChunkRectangle)
        //{
        //    _Tiles = Tiles;
        //    _ChunkRectangle = ChunkRectangle;
        //}

        //protected WorldChunk(Rectangle ChunkRectangle)
        //{
        //    _ChunkRectangle = ChunkRectangle;
        //    _Width = _ChunkRectangle.Width;
        //    _Height = _ChunkRectangle.Height;

        //    _Tiles = new Tile[_ChunkRectangle.Width * _ChunkRectangle.Height];
        //}

        //public bool IsTileClear(MapLocation tile)
        //{
        //    if(tile.X < 0 || tile.Y < 0)
        //        return false;

        //    Tile t = _Tiles[_Width * tile.Y + tile.X];

        //    if (t.SpriteID.ID == SpriteID.EmptyID.ID)
        //        return true;
        //    else
        //        return false;
        //}

        //public static WorldChunk GetWorldChunk(Rectangle currentView, ArrayList Maps)
        //{
        //    WorldChunk Chunk = new WorldChunk(currentView);

        //    Rectangle dView = new Rectangle(currentView.X, currentView.Y, currentView.Width, currentView.Height);

        //    foreach (TileMap tm in Maps)
        //    {
        //        //Our initial Chunk area will be the whole map.
        //        Rectangle drawArea = new Rectangle(tm.WorldX, tm.WorldY, TileMap.MapWidth, TileMap.MapHeight);
        //        //Our corrected Drawing area will be intersection rectangle between two viewable area and map area rectangles
        //        drawArea = RectangleTools.Intersect(drawArea, dView);

        //        for (int y = 0; y < drawArea.Height; y++)
        //        {
        //            for (int x = 0; x < drawArea.Width; x++)
        //            {
        //                //  Take the current row, multiply it by the width of a row, and then add the column value.
        //                Tile TerrainTile = tm.GroundCollisionLayer.Tiles[TileMap.MapWidth * (drawArea.Y - tm.WorldY + y) +
        //                    drawArea.X - tm.WorldX + x];

        //                //Add Tile to Collection                        
        //                Chunk._Tiles[Chunk._Width * y + x] = TerrainTile;
        //            }
        //        }
        //    }

        //    return Chunk;
        //}
    }
}
